﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using XXX.Models;
using XXX.Models.XXXEntities;
 
using GLY_XieTong;
using XXX.Common;

namespace XXX.Bo
{
    /// <summary>
    /// 实现BOM取数，主从表，嵌套
    /// </summary>
    public class MockU8XieTongRepository : IU8XieTongRepository
    {


        public RetModel AddU8XieTong(U8XieTong u8XieTong)
        {
            RetModel retModel = new RetModel();
            try
            {
                XieTong XT = new XieTong(CanShu.conStrInter, u8XieTong.IDBId);
                //XT.iInterval = Convert.ToInt32(XXX.Common.AppSettings.GetAppSeting("Interval"));
                //XT.cConStrZD = DbHelper.conStrZD;

                //idbid 没有作用，还是全部处理的
                retModel.message = XT.InsAll(u8XieTong.CLx, u8XieTong.cFilter, u8XieTong.IDBId);


                if (retModel.message == "")
                {
                    retModel.code = 200;
                    retModel.message = "协同处理成功！";
                }
                else
                {
                    retModel.code = 500;
                }
            }
            catch (Exception ex)
            {
                retModel.code = 500;
                retModel.message = ex.Message;


            }
            return retModel;


        }

        public RetModel UpdateKQXieTong(U8XieTong u8XieTong)
        {
            RetModel retModel = new RetModel();
            //try
            //{
            //    TongBu XT = new TongBu(DbHelper.conStr, u8XieTong.IDBId);
            //    XT.cConStrZD = DbHelper.conStrZD;

            //    if (u8XieTong.CLx == "刷卡记录")
            //    {
            //        retModel.message = XT.UpdateKaoqin(u8XieTong.CLx);

            //    }
              

            //    if (retModel.message == "")
            //    {
            //        retModel.code = 200;
            //        retModel.message = "协同处理成功！";
            //    }
            //    else
            //    {
            //        retModel.code = 500;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    retModel.code = 200;
            //    retModel.message = ex.Message;


            //}
            return retModel;


        }

        //单据协同
        public RetModel YZDXieTong(U8XieTong u8XieTong)
        {
            RetModel retModel = new RetModel();
            ////取配置的连接字符串
            //XieTong YzdXieTong = new XieTong(DbHelper.conStr, u8XieTong.IDBId);
            

            //    retModel.message = YzdXieTong.InsMultiVouch(u8XieTong.CLx, u8XieTong.cFilter, out int idout, out string ccode2);

            //    if (retModel.message == "")
            //    {
            //        retModel.code = 200;
            //        retModel.message = "协同处理成功！";
            //    }
            //    else
            //    {
            //        retModel.code = 500;
            //    }
            
            return retModel;


        }

        //不同表档案协同
        public RetModel YZDRecordXieTong(U8XieTong u8XieTong)
        {
            RetModel retModel = new RetModel();
            //取配置的连接字符串
            //XieTong YzdXieTong = new XieTong(DbHelper.conStr, u8XieTong.IDBId);


            //retModel.message = YzdXieTong.RecordToRecordNew(u8XieTong.CLx);

            //if (retModel.message == "")
            //{
            //    retModel.code = 200;
            //    retModel.message = "协同处理成功！";
            //}
            //else
            //{
            //    retModel.code = 500;
            //}

            return retModel;


        }
    }
}
